﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FluentNHibernate.Mapping;
using YasharEl.Infrastructure.Core.Personification;
using YasharEl.Infrastructure.ProcessEngine.EntityModel;

namespace YasharEl.Infrastructure.ProcessEngine.PersistenceModel.NHibernate.Mappings
{
    public class ProcessParticipantEntityMap : ClassMap<ProcessParticipantEntity>
    {
        public ProcessParticipantEntityMap()
        {
            ReadOnly();

            Table("Participants");

            Id(e => e.ParticipantId)
                .Column("ParticipantId")
                    .GeneratedBy.Assigned();

            Component<Name>(e => e.UserName,
                nameEntity =>
                {
                    nameEntity.Access.Property();
                    nameEntity.Map(n => n.Firstname)
                        .Column("Firstname")
                        .Not.Nullable()
                        .Length(100);
                    nameEntity.Map(n => n.Lastname)
                        .Column("Lastname")
                        .Not.Nullable()
                        .Length(100);
                }
            );

            Map(e => e.Email)
                .Column("Email")
                .Not.Nullable()
                .Length(100)
                .Unique();
        }
    }
}
